home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / Disassembler68k.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-18  |  5.6 KB  |  155 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:            Disassmbler68k.h
  3.     
  4.     Contains:        New interface to 68k Disassembler.
  5.     
  6.     Copyright:        © 1983-1995 by Apple Computer, Inc.
  7.                     All rights reserved.
  8.     
  9.     Rearchitect:    Chris Thomas
  10.     
  11.     Created:        In a quaint hut by the side of an obscure country
  12.                     road, Londonshire, England.
  13. */
  14.  
  15. #ifndef __DISASMLOOKUP__
  16. #define __DISASMLOOKUP__
  17.  
  18. #ifndef __TYPES__
  19. #include <Types.h>
  20. #endif
  21.  
  22. #ifndef __MIXEDMODE__
  23. #include <MixedMode.h>
  24. #endif
  25.  
  26. /** distinguish the version **/
  27. enum
  28. {
  29.     disassembler68kversion = 3
  30. };
  31.  
  32. /** base register definitions  **/
  33. typedef enum {_A0_, _A1_, _A2_, _A3_, _A4_, _A5_, _A6_, _A7_, _PC_, _ABS_, _TRAP_, _IMM_} LookupRegs;
  34.  
  35. /** MixedMode stuff and procedure definitions **/
  36.  
  37. /*
  38.  *    note:    We decided against MixedMode for the simple reason that it would be useless
  39.  *            in this situation.  Should this evaluation change, UPPs and stuff still exist.
  40.  */
  41.  
  42. typedef pascal void (*PCRelativeProcPtr)        (SInt32 inRelativeAddress, unsigned char *outString);
  43. typedef pascal void (*JumpTableOffsetProcPtr)    (SInt16 inA5offset, unsigned char *outString);
  44. typedef pascal void (*TrapNameProcPtr)            (UInt16 inTrapWord, unsigned char *outString);
  45. typedef pascal void (*AbsoluteAddrProcPtr)        (SInt32 inAbsoluteAddress , unsigned char *outString);
  46. typedef pascal void (*RegisterOffsetProcPtr)    (LookupRegs inBaseReg, SInt32 inOffset, unsigned char *outString);
  47. typedef pascal void (*ImmediateDataProcPtr)        (SInt32 inData, unsigned char *outString);
  48. typedef pascal void (*LookupProcPtr)            (Ptr inPC, LookupRegs inBaseReg, SInt32 inOperand, unsigned char *outString);
  49.  
  50. typedef PCRelativeProcPtr        PCRelativeUPP;
  51. typedef JumpTableOffsetProcPtr    JumpTableOffsetUPP;
  52. typedef TrapNameProcPtr            TrapNameUPP;
  53. typedef AbsoluteAddrProcPtr        AbsoluteAddressUPP;
  54. typedef RegisterOffsetProcPtr    RegisterOffsetUPP;
  55. typedef ImmediateDataProcPtr    ImmediateDataUPP;
  56. typedef LookupProcPtr            LookupUPP;
  57.  
  58. #define CallPCRelativeProc(x, inAddress, outString) \
  59.         x(inAddress, outString)
  60.  
  61. #define CallJumpTableProc(x, inAddress, outString) \
  62.         x(inAddress, outString)
  63.  
  64. #define CallTrapNameProc(x, inAddress, outString) \
  65.         x(inAddress, outString)
  66.  
  67. #define CallAbsoluteAddressProc(x, inAddress, outString) \
  68.         x(inAddress, outString)
  69.  
  70. #define CallRegisterOffsetProc(x, inRegs, inAddress, outString) \
  71.         x(inRegs, inAddress, outString)
  72.  
  73. #define CallImmediateDataProc(x, inAddress, outString) \
  74.         x(inAddress, outString)
  75.  
  76. #define CallLookupProc(x, ptr, regs, value, string) \
  77.         x(ptr, regs, value, string)
  78.  
  79. /** options & results **/
  80.  
  81. typedef enum
  82. {
  83.     dis68k_useClassicMnemonics = (1 << 0),            /*not impl- use old-style, capitalized, less accurate mnemonics*/
  84.     dis68k_capitalize = (1 << 1),                    /*not impl- capitalize the mnemonics, but with accuracy*/
  85.     dis68k_use_C_Formatting = (1 << 2),                /*output C-style 0xHex instead of $Hex etc*/
  86.     dis68k_default = 0                                /*don't use any of the above options*/
  87. }Dis68kOptions;
  88.  
  89. typedef enum
  90. {
  91.     dis68k_invalid =    (UInt32)    (1 << 0),    /* instruction is invalid - won't run on any 68k */
  92.     dis68k_68000 =    (UInt32)            (1 << 1),    /* instruction runs on 68000 */
  93.     dis68k_68010 =    (UInt32)            (1 << 2),    /* instruction runs on 68010 */
  94.     dis68k_68020 =    (UInt32)            (1 << 3),    /* instruction runs on 68020 */
  95.     dis68k_68030 =    (UInt32)            (1 << 4),    /* instruction runs on 68030 */
  96.     dis68k_68040 =    (UInt32)            (1 << 5),    /* instruction runs on 68040 */
  97.     dis68k_68060 =    (UInt32)            (1 << 5),    /* instruction runs on 68060 */
  98.                                             /* %%% (need this option be seperate?)
  99.                                             I think the 060 is just a hypersupercharged 040
  100.                                             Leave a bit for it just in case*/
  101.     dis68k_privileged =    (UInt32)        (1 << 7),    /* instruction is supervisor-mode */
  102.     dis68k_branch =        (UInt32)        (1 << 8),    /* instruction might branch */
  103.     dis68k_family =        (UInt32)                    /* runs on any 68k cpu*/
  104.         (dis68k_68000 | dis68k_68010 | dis68k_68020 | dis68k_68030 | dis68k_68040 | dis68k_68060),
  105.     
  106.     dis68k_010orLater = (UInt32)    (dis68k_family ^ dis68k_68000),
  107.     dis68k_020orLater = (UInt32)    (dis68k_family ^ (dis68k_68000 | dis68k_68010)),
  108.     
  109.     dis68k_endz
  110. }Dis68kResults;
  111.  
  112.  
  113. /** implementation **/
  114.  
  115. #ifdef __cplusplus
  116. extern "C" {
  117. #endif
  118.  
  119. /*returns Dis68kResults*/
  120. extern pascal UInt32 Disassembler(        long        commentAdjust,             /* Address adjustment (added to PC-relative commented values)    */
  121.                                         short        *bytesUsed,             /* Bytes used up by 1 call        */  
  122.                                         Ptr            data,                    /* Ptr to instruction to be disassembled    */
  123.                                         Str255        opcode,                     /* Ptr to opcode string         */
  124.                                         Str255        operand,                 /* Ptr to operand string        */
  125.                                         Str255        comment,                 /* Ptr to comment string         */
  126.                                          LookupUPP     lookUpProc);            /* UPP to Lookup procedure        */
  127.  
  128. extern pascal void Dis68kSetOptions(Dis68kOptions inOptions);
  129.  
  130. /* typed version of InitLookup */
  131. extern pascal void SetLookupProcs(PCRelativeUPP pcrProc, JumpTableOffsetUPP jtoProc, TrapNameUPP trapProc,
  132.                     AbsoluteAddressUPP aaProc, RegisterOffsetUPP idProc, ImmediateDataUPP immProc);
  133.  
  134. extern pascal void InitLookup(Ptr pcrProc, Ptr jtoProc, Ptr trapProc,
  135.                     Ptr aaProc, Ptr idProc, Ptr immProc);
  136.  
  137. extern pascal void Lookup(    Ptr            PC,            /* Addr of extension/trap word        */
  138.                             LookupRegs    BaseReg,     /* Base register/lookup mode          */
  139.                             SInt32        Opnd,        /* Trap word, PC addr, disp.          */
  140.                             Str255        S);             /* Returned substitution            */
  141.  
  142. extern pascal void LookupTrapName(unsigned short TrapWord, char *S);
  143. extern pascal void ModifyOperand(char *operand);
  144.  
  145. extern pascal char *endOfModule(void *address, void *limit, char *symbol, void **nextModule);
  146. extern pascal char *showMacsBugSymbol(char *symStart, void *limit, char *operand,
  147.                                                              short *bytesUsed);
  148.  
  149. extern pascal char *validMacsBugSymbol(char *symStart, void *limit, char *symbol);
  150.  
  151. #ifdef __cplusplus
  152. }
  153. #endif
  154. #endif
  155.